import { Controller } from '@nestjs/common';
import { ToolResponse } from '../type';
import { Tool } from '@rekog/mcp-nest';
import { z } from 'zod';

@Controller('acquires-current-time')
export class AcquiresCurrentTimeController {
  @Tool({
    name: 'acquires-current-time',
    description: '获取当前时间',
    parameters: z
      .object({
        timezone: z.string().describe('时区').default('Asia/Shanghai')
      })
      .required()
  })
  async exec({
    timezone
  }: {
    // 时区
    timezone: string;
  }): Promise<ToolResponse> {
    if (!timezone) {
      return {
        content: [
          {
            type: 'text',
            text: '时区不能为空'
          }
        ]
      };
    }
    return {
      content: [
        {
          type: 'text',
          text: new Date().toLocaleString('zh-CN', { timeZone: timezone })
        }
      ]
    };
  }
}
